package com.pauldada.sakurabbs.services.impl;

import com.pauldada.sakurabbs.dao.LinkRepository;
import com.pauldada.sakurabbs.entities.Link;
import com.pauldada.sakurabbs.services.LinkService;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

//链接Service实现类
@Service("linkService")
public class LinkServiceImpl implements LinkService{

	@Resource
	private LinkRepository linkRepository;
	
	@Override
	public List<Link> list(Integer page,Integer pageSize) {
		return linkRepository.findAll(PageRequest.of(page,pageSize)).getContent();
	}

	@Override
	public Long getCount() {
		return linkRepository.count();
	}

	@Override
	public void save(Link link) {
		linkRepository.save(link);
	}

	@Override
	public void delete(Integer id) {
		linkRepository.deleteById(id);
	}

	@Override
	public List<Link> listAll() {
		return linkRepository.findAll();
	}
	

	
}
